<?php

App::uses('RealtyAppModel', 'Realty.Model');

/**
 * Category
 *
 * @category Model
 * @package  Croogo.Category.Model
 * @version  1.0
 * @author   Kalistratov Sergey Mihailovich <kalistratov.s.m@gmail.com>
 * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
 * @link     http://www.croogo.org
 */

class Category extends RealtyAppModel{

/**
 * Display fields for this model
 *
 * @var string
 */
	public $displayField = 'title';

	public $actsAs = array(
		'Tree' => array(
			'parent' => 'category_id',
		),
	);

/**
 * Validation
 *
 * @var array
 * @access public
 */
	public $validate = array(
		'alias' => array(
			'rule' => 'notEmpty',
			'required'  => true,
			'message' => 'Alias cannot be empty.',
		),
		'title' => array(
			'rule' => 'notEmpty',
			'required'  => true,
			'message' => 'title cannot be empty.',
		),
	);

/**
 * Model associations: belongsTo
 *
 * @var array
 */
	public $belongsTo = array(
		'ParentCategory' => array(
			'className' => 'Category',
			'foreignKey' => 'category_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);
}